package com.liuyk.widget;

import android.content.Context;
import android.graphics.Canvas;

import androidx.annotation.Nullable;

import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.LinearLayout;

/**
 * Created by Administrator on 2015/10/10.
 */
public class FloorLayout extends LinearLayout {
    private static final String TAG = "View";

    public FloorLayout(Context context) {
        this(context, null);
    }

    public FloorLayout(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public FloorLayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        Log.e(TAG, "ViewGroup:" + "dispatchTouchEvent...");
        return super.dispatchTouchEvent(ev);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        Log.e(TAG, "ViewGroup:" + "onInterceptTouchEvent...");
        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                Log.e(TAG, "ViewGroup:" + "onInterceptTouchEvent...down");
                break;

            case MotionEvent.ACTION_MOVE:
                Log.e(TAG, "ViewGroup:" + "onInterceptTouchEvent...move");
                break;

            case MotionEvent.ACTION_UP:
                Log.e(TAG, "ViewGroup:" + "onInterceptTouchEvent...up");
                break;
        }
        return super.onInterceptTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.e(TAG, "ViewGroup:" + "onTouchEvent...");
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                Log.e(TAG, "ViewGroup:" + "onTouchEvent...down");
                break;

            case MotionEvent.ACTION_MOVE:
                Log.e(TAG, "ViewGroup:" + "onTouchEvent...move");
                break;

            case MotionEvent.ACTION_UP:
                Log.e(TAG, "ViewGroup:" + "onTouchEvent...up");
                break;
        }
        return true;
    }

    private void init() {
        this.setOrientation(LinearLayout.VERTICAL);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        Log.e(TAG, "Parent: " + "onMeasure");
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
    }

}

